/*
 * BuildingExpert.h
 *
 *  Created on: Nov 21, 2008
 *      Author: Ryan
 */

#ifndef BUILDINGEXPERT_H_
#define BUILDINGEXPERT_H_

#include "../../../OOInterface/Objects/Player.h"
#include "../../../OOInterface/Objects/Point3.h"

#include "../../../OOInterface/AIInterface.h"
#include "../../../OOInterface/Interfaces/GameListener.h"

#include "../ResourceAnalysisUnit.h"
#include "../UnitAnalyzers/FilterVisitor.h"
#include "InfrastructureMap.h"
#include "ResourceReservation.h"

class BuildingExpert
{
public:
	BuildingExpert( OOInterface::AIInterface* i, OOInterface::ConstPlayerPtr self, ResourceReservation* reserve );
	virtual ~BuildingExpert();

	void run();

private:
	OOInterface::AIInterface* _i;
	OOInterface::ConstPlayerPtr _self;
	ResourceReservation* _reservation;
	InfrastructureMap _infrastructure;

	OOInterface::ConstUnitSet _generators;
	OOInterface::ConstUnitSet _extractors;
	OOInterface::ConstUnitSet _factories;
	OOInterface::ConstUnitSet _idleBuilders;


	ResourceNodes _idealExtractorLocations;
	ResourceNodes _builtExtractors;

	void updateBuilderList();
	void updateList( FilterVisitor& filter, OOInterface::ConstUnitSet& list, ResourceMap availableResources );


	float findMaxExtractorRadius();

	bool factoryAndDefenses();
	bool extractorsAndGenerators( const OOInterface::Resource imbalanceResource, bool imbalance );

	void giveOrder( OOInterface::ConstUnitPtr builder, OOInterface::ConstCommandPtr command, ResourceMap cost );
};

#endif /* BUILDINGEXPERT_H_ */
